<?php

App::uses('Shell', 'Console');
App::uses('ConfigurationKeys', 'ConfigurationKeys.Lib');

class TestJoinedDocumentRegexShell extends AppShell {

    /**
     * get the option parser.
     *
     * @return void
     */
    public function getOptionParser() {
        $parser = parent::getOptionParser();

        $parser->addOption('pattern', array(
            'default' => ConfigurationKeys::getKeyValue('joined_document_regex'),
        ));

        return $parser;
    }

    public function main() {
        $this->stdout->styles('flashy', array('text' => 'magenta', 'blink' => true));

        foreach (ClassRegistry::init('RawFile')->find('all') as $rawFile) {
            $sourceDocumentId = ClassRegistry::init('SourceDocument')->buildIdFromFileName(
                $rawFile['RawFile']['name']
                , $this->params['pattern']
            );

            $this->out($rawFile['RawFile']['name'] . ' -> <flashy>' . $sourceDocumentId . '</flashy>');
        }

        $this->hr();
        $this->out('Pattern: ' . $this->params['pattern']);
        $this->hr();
    }

}